package com.csk.zsk.compents.utils;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class URLUtils {

	public static String readContentFromUrl(String urlPath, String encoding) {
		if (encoding == null) {
		}
		try {
			URL url = new URL(urlPath);
			StringBuilder sb = new StringBuilder();
			URLConnection urlConnection = url.openConnection();// 打开url连接
			BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), encoding));
			String line = null;
			while ((line = br.readLine()) != null) {
				sb.append(line + "\n");
			}
			return sb.toString();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}

	}

}
